package com.saifan.wyy_ov.utils;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;

import com.saifan.wyy_ov.R;


/**
 * @author Wangli
 * @Description: 拨打电话工具类
 * @date: 2015/5/26 17:52
 * @version: V1.0
 */
public class CallPhoneUtil {
    public static void callPhone(final Context context, final String phone){
        if (StringUtil.isNullOrEmpty(phone.trim())){
            ToastUtil.showToast(context, "电话号码为空不能拨号");
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(context);

        builder.setTitle("您确定要拨打电话：" + phone);

//        builder.setMessage("您确定要拨打电话：" + phone);


        builder.setIcon(android.R.drawable.ic_menu_call);

        builder.setPositiveButton("确定", new DialogInterface.OnClickListener() {
            Intent intent;

            @Override
            public void onClick(DialogInterface dialog, int which) {
                intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
                context.startActivity(intent);
            }
        });

        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });

        builder.create().show();
    }
}
